﻿<UserControl x:Class="BinaryXmlInspector.BinaryXmlViewer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:this="clr-namespace:BinaryXmlInspector"
    Height="Auto" Width="Auto">
    <UserControl.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="FontFamily" Value="{Binding Path=FontFamily}" />
            <Setter Property="FontSize" Value="{Binding Path=FontSize}" />            
            <Setter Property="Focusable" Value="False" />
            <Setter Property="TextWrapping" Value="NoWrap" />
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="IsReadOnly" Value="False" />
            <Setter Property="FontFamily" Value="{Binding Path=FontFamily}" />
            <Setter Property="FontSize" Value="{Binding Path=FontSize}" />
            <Setter Property="MaxLines" Value="1" />
        </Style>
        <Style TargetType="{x:Type Control}">
            <Setter Property="Background" Value="{Binding Path=EnableColor}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=ReadOnly}" Value="True">
                    <Setter Property="Background" Value="{Binding Path=DisableColor}" />
                </DataTrigger> 
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid>
        <DockPanel LastChildFill="True">                        
            <DockPanel DockPanel.Dock="Bottom" LastChildFill="True">
                <TextBlock Text="{Binding LinePosition}" DockPanel.Dock="Left" />
                <TextBlock Text="{Binding BytePosition}" DockPanel.Dock="Left" />
                <Button Click="OpenWithClick" TabIndex="60" DockPanel.Dock="Right" >
                    <TextBlock Text="Open With..." IsEnabled="False" />
                </Button>
                <Button Click="OpenClick" TabIndex="50" DockPanel.Dock="Right" >
                    <TextBlock Text="Open" IsEnabled="False" />
                </Button>
                <ToggleButton Click="ExplodeClick" TabIndex="40" DockPanel.Dock="Right" IsChecked="{Binding Explode}">
                    <TextBlock Text="Explode" />
                </ToggleButton>
                <ToggleButton Click="PrettyClick" TabIndex="30" DockPanel.Dock="Right" IsChecked="{Binding Pretty}">
                    <TextBlock Text="Pretty" />
                </ToggleButton>
                <TextBox x:Name="Find" Margin="30,0,0,0" MinWidth="100" TabIndex="20" AcceptsReturn="False" 
                         IsReadOnly="False" PreviewKeyDown="SearchKeyPress" IsEnabled="False" />
            </DockPanel>
            <RichTextBox x:Name="XmlView" TextChanged="XmlChanged" AcceptsReturn="True" ScrollViewer.CanContentScroll="True" 
                         VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" TabIndex="10">
                <RichTextBox.Resources>
                    <Style TargetType="{x:Type Paragraph}">
                        <Setter Property="Margin" Value="0"/>
                        <Setter Property="FontSize" Value="{Binding Path=FontSize}"/>
                        <Setter Property="FontFamily" Value="Consolas"/>
                    </Style>
                </RichTextBox.Resources>
            </RichTextBox>
        </DockPanel>
    </Grid>
</UserControl>
